<?php
namespace Admin\Controller;

class PersonController extends BaseController{
	public function upd(){
		$person=session('admin');
		//连表查询
		$admin = new \Model\AdminModel();
		if(IS_POST){

			$info=$admin->create($_POST,2);

			
				if($info){
					$info['pwd']=md5($info['pwd']);
					
					$z=$admin->save($info);
					//dump($z);
					//dump($info);
					//die();
					if($z || $z===0){
					
					
                    $this -> redirect('Index/index',array(),2,'修改成功');
                	}	
                	else{
                    $this -> redirect('upd',array(),2,'修改失败');
                	}
				}
				else{

                $this -> assign('errorinfo',$admin->getError());
			}
			
		}
		else{
		$info=$admin->table('tp_admin a ,tp_apurview b')->where("a.power=b.admin_id and a.admin_name='$person'")->find();
		//dump($info);
		
		//dump($info['power']);
		//die();
		$this->assign('info',$info);

		
		}
		$this->display();
	}
	
}